/*
 * 查询报警
 * */
package com.axt.dbaudit.bean.query;

import java.util.List;

import com.axt.dbaudit.base.MsgFuncExt;
import com.axt.dbaudit.base.QueryFilter;
import com.axt.dbaudit.base.QueryType;
import com.axt.dbaudit.model.query.Alarm;
import com.axt.dbaudit.model.query.AlarmDetail;

public class QueryAlarmBean extends QueryBaseBean {
	
	public List<Alarm> getAlarms() {
		try {
			return (List<Alarm>)getRecord();
		} catch (Exception e) {
			return null;
		}
	}
	
	public List<AlarmDetail> getAlarmDetails() {
		try {
			return (List<AlarmDetail>)getRecord();
		} catch (Exception e) {
			return null;
		}
	}
	
	/* query alarm indices */
	public int queryAlarmIndices(
			String serverPath, List<QueryFilter> filters, int queryInResult, int maxRowNum) {
		
		init();
		setQueryType(QueryType.QUERY_T_ALARM_IDX);
		setQueryInResult(queryInResult);
		setMaxRowNum(maxRowNum);
		setFilters(filters);
		
		return query( MsgFuncExt.FUNC_QUERY_QUERY_INDEX, serverPath);
	}
	
	/* query alarms */
	public int queryAlarms(String serverPath, List<QueryFilter> filters) {
		
		init();
		setQueryType(QueryType.QUERY_T_ALARM);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_DATA, serverPath, 
				"com.axt.dbaudit.model.query.Alarm");
	}
	
	/* query process maxRowNul = 0 */
	public int queryProcess(String serverPath, List<QueryFilter> filters) {
		
		init();
		setQueryType(QueryType.QUERY_T_ALARM);
		setMaxRowNum(0);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_DATA, serverPath, 
				"com.axt.dbaudit.model.query.Alarm");
	}
	
	/* stop query alarm indices */
	public int stopQueryIndices(String serverPath){
		init();
		setQueryType(QueryType.QUERY_T_ALARM_IDX);
		
		return query(MsgFuncExt.FUNC_QUERY_STOP_LIST_IDX, serverPath);
	}
	
	/* query alarm detail by alarmId */
	public int queryAlarmDetail(String serverPath, List<QueryFilter> filters){
		
		init();
		setQueryType(QueryType.QUERY_T_ALARM_DETAIL);
		setQueryInResult(0);
		setMaxRowNum(1);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_NORMAL, serverPath, 
				"com.axt.dbaudit.model.query.AlarmDetail");
	}
}
